from bilibili_api import search, sync
from fastmcp import FastMCP

mcp = FastMCP("Bilibili MCP Server(by xueshanlinghu)")

# uv 管理项目
# uv init
# uv add bilibili-api-python fastmcp
# 运行
# uv run bilibili-mcp-server.py

# bilibili-api-python 文档
# https://nemo2011.github.io/bilibili-api/#/
# search 搜索部分
# https://nemo2011.github.io/bilibili-api/#/examples/search


@mcp.tool()
def keyword_search(keyword: str) -> dict:
    """
    按关键词进行结果搜索，返回搜索结果dict
    """
    search_result = sync(search.search(keyword))
    return search_result


if __name__ == "__main__":
    # result = keyword_search("MCP")
    # print(f"搜索结果：{result}")

    mcp.run()
